package com.edu.compile.template.ftl.node;

import com.alibaba.fastjson.JSONObject;
import com.edu.compile.template.ftl.CommonNodeTemplateParse;
import com.edu.model.constant.EventConstant;

public class Redis extends CommonNodeTemplateParse {

    public Redis(String eventId, String nodeId, String nodeType, String nodeName, String parentNodeId) {
        super(nodeId, nodeType, nodeName, parentNodeId);
    }

    private String opeType;

    private String key;

    private String value;

    private String input;

    public String getOpeType() {
        return opeType;
    }

    public void setOpeType(Integer opeType) {
        if (opeType == EventConstant.DbConstant.INSERT) {
            this.opeType = "set";
        } else if (opeType == EventConstant.DbConstant.DELETE) {
            this.opeType = "del";
        } else if (opeType == EventConstant.DbConstant.QUERY) {
            this.opeType = "get";
        } else {
            throw new IllegalArgumentException("Redis operate error, reference EventConstant.DbConstant");
        }
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getInput() {
        JSONObject object = new JSONObject();
        object.put("key", this.getKey());
        object.put("value", this.getValue());
        return object.toJSONString();
    }

    public void setInput(String input) {
        this.input = input;
    }

}
